
import os
from selenium import webdriver
import time

# 打开浏览驱动器
driver = webdriver.Chrome()
driver.implicitly_wait(3)

# 将浏览器最大化
driver.maximize_window()

# 获取当前目录的selen.html文件
file_path = os.path.join('file:///', os.getcwd(), "selenium.html")
driver.get(file_path)

# 定位元素并操作元素
username_element = driver.find_element_by_css_selector('div#signup input[name="username"]')
password_element = driver.find_element_by_css_selector('div#signup input[name="password"]')
sign_button = driver.find_element_by_css_selector('div#signup input.sub')
username_element.send_keys("rabbit")
password_element.send_keys("love")
sign_button.click()
time.sleep(1)

if driver.find_element_by_id('signup').is_displayed():
    print("注册成功")
else:
    print("注册失败")

time.sleep(1)
# 关闭浏览器
driver.quit()